import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { TestStepVO, TestStepForm, TestStepQuery } from '@/api/core/testStep/types';

/**
 * 查询实验步骤列表
 * @param query
 * @returns {*}
 */

export const listTestStep = (query?: TestStepQuery): AxiosPromise<TestStepVO[]> => {
  return request({
    url: '/core/testStep/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询实验步骤详细
 * @param stepId
 */
export const getTestStep = (stepId: string | number): AxiosPromise<TestStepVO> => {
  return request({
    url: '/core/testStep/' + stepId,
    method: 'get'
  });
};

/**
 * 新增实验步骤
 * @param data
 */
export const addTestStep = (data: TestStepForm) => {
  return request({
    url: '/core/testStep',
    method: 'post',
    data: data
  });
};

/**
 * 修改实验步骤
 * @param data
 */
export const updateTestStep = (data: TestStepForm) => {
  return request({
    url: '/core/testStep',
    method: 'put',
    data: data
  });
};

/**
 * 删除实验步骤
 * @param stepId
 */
export const delTestStep = (stepId: string | number | Array<string | number>) => {
  return request({
    url: '/core/testStep/' + stepId,
    method: 'delete'
  });
};
